﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpLib
{
    public class Prize
    {
        public string Description { get; private set; }
        public int Value { get; private set; }
        public Prize(string description, int value)
        {
            this.Description = description;
            this.Value = value;
        }
    }

    public abstract class KujibikiProcesser
    {
        public abstract Prize GetPrize();
    }

    public interface IKujibikiProcesser
    {
        Prize GetPrize();
    }

    internal class KujibikiProcesser_Kaden : KujibikiProcesser
    {
        private Random rnd = new Random();
        internal KujibikiProcesser_Kaden() { }

        public override Prize GetPrize()
        {
            var id = rnd.Next(1, 100);

            if (id >= 1 && id <= 25)
                return new Prize("カメラです", 20000);
            if (id >= 26 && id <= 50)
                return new Prize("Androidじゃないほうのスマホです", 50000);
            else
                return new Prize("ハズレwww", 0);
        }
    }

    public class Kujibiki
    {
        private int insertedCoin;
        private KujibikiProcesser kujiProc = new KujibikiProcesser_Kaden();
        public int OneGameCoin { get; set; }

        public Kujibiki()
        {
            OneGameCoin = 100;
            insertedCoin = 0;
        }

        internal Kujibiki(KujibikiProcesser kujiProc)
            : this()
        {
            this.kujiProc = kujiProc;
        }

        public void InsertCoin(int coin)
        {
            this.insertedCoin += coin;
        }

        public Prize DrawLottery()
        {
            if (insertedCoin < OneGameCoin)
                throw new Exception("一回" + OneGameCoin + "コインが必要です。");
            insertedCoin -= OneGameCoin;
            return kujiProc.GetPrize();
        }
    }
}
